﻿@{
    ViewBag.Title = "Add";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<link href="/Content/uploadify.css" rel="stylesheet" />
<script src="/Scripts/jquery.uploadify.js"></script>
<style type="text/css">
    .uploadify-button {
        /*background: url("/Content/img/upload1.png");*/
        border: 0;
        border-radius: 0;
        display: inline-block;
        margin-left: 1px;
        position: absolute;
        top: 0;
        left: 0;
    }

    .makefriend .tag .btn {
        width: 100%;
        height: 20px;
        border-radius: 0px;
        font-size: 12px;
        background-color: #fb9337;
        color: #fff;
        box-shadow: -2px 2px rgba(158, 153, 153, 0.47);
        margin: 0 10px 0 0;
        padding: 3px 6px;
        text-align: center;
        display: inline;
        white-space: normal;
    }

    .makefriend .btn {
        width: 100px;
        height: 40px;
        background-color: #d93467;
        border-radius: 8px;
        font-size: 18px;
        display: inline-block;
        box-shadow: -1px 1px #ddd;
    }

        .makefriend .btn:hover {
            background-color: #d93467;
        }
    /*.makefriend .modal-dialog{
      width: 320px;
      margin: 350px auto 0;
      text-align: center;
    }*/
    .makefriend .modal-content {
        width: 320px;
        padding: 30px 40px 20px;
        margin: 10% auto 0;
        text-align: center;
    }

    .makefriend .hislabel {
        width: 100%;
        /*text-align: left;*/
        font-size: 12px;
    }

    .makefriend .level {
        text-align: center;
    }

    .expdiv {
        padding: 4px;
        width: 80px;
        border: 1px solid #c8c8c8;
        float: left;
    }

    .expbtn {
        position: absolute;
        z-index: 2;
        margin: -15px 0px 0px 50px;
    }

        .expbtn a {
            display: block;
            width: 32px;
            height: 32px;
            background: #fff;
            background: url(/Content/img/Stop.png);
        }

    /*.expbtn a:hover {
        background: url(../images/btn_playbg.gif) left -16px;
    }*/
</style>
<script charset="utf-8" src="/Content/kindeditor/kindeditor-min.js"></script>
<script charset="utf-8" src="/Content/kindeditor/lang/zh_CN.js"></script>
@model YTCMS.Domain.Entities.guide

<div class="page-header">
    <h1>
        <a href="/Guide/index"> 游记管理</a>
        <small>
            <i class="icon-double-angle-right"></i> 修改游记
        </small>
    </h1>
</div><!-- /.page-header -->

<div class="row">
    <div class="col-xs-12">
        <div class="row">
            <div class="col-xs-12 ">

            </div>
        </div>
        <div class="row">
            <div class="col-xs-12">
                <form class="form-horizontal" role="form" id="form1" method="post" action="/Guide/Edit">
                    <div class="form-group">
                        <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 标题 </label>
                        <div class="col-sm-9">
                            @Html.TextBoxFor(s => s.Title, new { @class = "col-xs-10 col-sm-5 required" })
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 发表用户 </label>
                        <div class="col-sm-9">
                            @Html.TextBoxFor(s => s.User, new { @class = "col-xs-10 col-sm-5 required" })
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 标题图片 </label>
                        <div class="col-sm-9">
                            <input type="file" name="file_upload" id="file_upload" maxlength="200" />
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 图片 </label>
                        <div class="col-sm-9" id="divimg">
                            <div class='expdiv'><div class='expbtn'><a href='javascript:void(0)' onclick='imgclose(this)' value='@Model.Images'></a></div><img src='@Model.Images' height='100px' width='80px' /></div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 游记分类 </label>
                        <div class="col-sm-9">
                            <div class="row">
                                <div class="col-md-3">
                                    @Html.DropDownList("ddl1", Admin.Common.YTDDL.Category(s => s.Pid.Value == 0 && s.Level == 1 && s.State == (int)YTCMS.Core.CommonState.正常, true), new { @class = "form-control", @onchange = "ddlonchange('ddl2','/Util/CategoryDDL',{pid:this.value},function(){$('#ddl3').empty().append('<option value=\"\">请选择</option>'); $('#CategoryId').val($('#ddl1').val())})" })
                                </div>
                                <div class="col-md-3">
                                    <select class="form-control" id="ddl2" name="ddl2" onchange="javascript: $('#CategoryId').val(this.value)">
                                        <option value="">请选择</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 出发日期 </label>
                        <div class="col-sm-9">
                            @Html.TextBoxFor(s => s.StartTime, new { @class = "col-xs-10 col-sm-5", onfocus = "WdatePicker({dateFmt: 'yyyy-M-d H:mm:ss' })" })
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 旅游天数 </label>
                        <div class="col-sm-9">
                            @Html.TextBoxFor(s => s.Day, new { @class = "col-xs-10 col-sm-5 " })
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 旅游费用 </label>
                        <div class="col-sm-9">
                            @Html.TextBoxFor(s => s.Money, new { @class = "col-xs-10 col-sm-5" })
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 旅游群体 </label>
                        <div class="col-sm-9">
                            @Html.TextBoxFor(s => s.Object, new { @class = "col-xs-10 col-sm-5 " })
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 标签 </label>
                        <div class="col-sm-9">
                            @Html.TextBoxFor(s => s.Tags, new { @class = "col-xs-10 col-sm-5 " })
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 是否推荐 </label>
                        <div class="col-sm-9">
                            @Html.RadioButtonFor(s => s.IsPush, 1) 是
                            @Html.RadioButtonFor(s => s.IsPush, 0) 否
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 备注 </label>
                        <div class="col-sm-9">
                            @Html.TextAreaFor(s => s.Remark, new { @class = "col-xs-10 col-sm-5 ", cols = "20", rows = "4", style = "margin: 0px; width: 767px; height: 76px;", @maxlength = 500 })
                        </div>
                    </div>

                    <div class="clearfix form-actions">
                        <div class="col-md-offset-3 col-md-9">
                            <button class="btn btn-info" type="button" id="btnSave">
                                <i class="icon-ok bigger-110"></i>
                                新增
                            </button>

                            &nbsp; &nbsp; &nbsp;
                            <button class="btn" type="reset">
                                <i class="icon-undo bigger-110"></i>
                                撤销
                            </button>
                        </div>
                    </div>
                    @Html.HiddenFor(s=>s.Id)
                    @Html.HiddenFor(s => s.PushTime)
                    @Html.Hidden("Images",Model.Images)
                    @Html.Hidden("CategoryId", Model.CategoryId)
                </form>
            </div><!-- /span -->
        </div><!-- /row -->
    </div><!-- /.col -->
</div><!-- /.row -->

<script>
    $(function () {
        jQuery("#form1").validate();
        $("#btnSave").click(function () {
            $("#form1").submit();
        });
        var editor;
        KindEditor.ready(function (K) {
            editor = K.create('textarea[name="Remark"]', {
                uploadJson: '/Util/KindEditorHandlerFile',
                afterBlur: function () { editor.sync(); },
                allowFileManager: true
            });
        });
    })

    setTimeout(function () {
        jQuery('#file_upload').uploadify({
            'swf': '/Scripts/uploadify.swf',
            'uploader': '/Util/ImgUploadAll?code=guide',
            'fileTypeExts': '*.gif; *.jpg; *.png; *.bmp; *.jpeg',
            'multi': false,
            'fileObjName': 'filedata',
            'wmode': 'transparent',
            'fileSizeLimit': '2MB',
            'onSelectError': function (file, errorCode, errorMsg) {
                jAlert("文件大小超出系统限制的", "提示")
            },
            'onFallback': function () {
                jAlert("您未安装FLASH控件，无法上传图片！请安装FLASH控件后再试。", "提示");
            },
            onUploadSuccess: function (file, data, respone) {
                $("#divimg").empty().append("<div class='expdiv'><div class='expbtn'><a href='javascript:void(0)' onclick='imgclose(this)' value='" + data + "'></a></div><img src='" + data + "' height='100px' width='80px' /></div>")
                $("#Images").val(data)
            }
        });
    }, 10);
    function imgclose(obj) {
        $(obj).parents(".expdiv").remove();
        imgs.remove($(obj).attr("value"));
    }
</script>